﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;

namespace Playbook.Core.ViewModel
{
    /// <summary>
    /// Represents an event.
    /// </summary>
    public sealed class EventViewModel : ViewModelBase
    {

        private Guid _id;
        private string _name;
        private string _description;
        private MemberViewModel _owner;
        private DateTime _eventDate;
        private bool _isRecurring;
        private int _recurringInterval;
        private EventIntervalTypes _recurringIntervalType;
        private bool _isActive;
        private ObservableCollection<CommentViewModel> _comments;
        private ObservableCollection<LibraryItemViewModel> _library;

        public EventViewModel() : base() { }

        /// <summary>
        /// Unique event identifier.
        /// </summary>
        public Guid ID { get { return _id; } set { _id = value; base.RaisePropertyChanged("ID"); } }

        /// <summary>
        /// Name of the event.
        /// </summary>
        public string Name { get { return _name; } set { _name = value; base.RaisePropertyChanged("Name"); } }

        /// <summary>
        /// Description of the event.
        /// </summary>
        public string Description { get { return _description; } set { _description = value; base.RaisePropertyChanged("Description"); } }

        /// <summary>
        /// Creator/owner of the event.
        /// </summary>
        public MemberViewModel Owner { get { return _owner; } set { _owner = value; base.RaisePropertyChanged("Owner"); } }

        /// <summary>
        /// Date of the event.
        /// </summary>
        public DateTime EventDate { get { return _eventDate; } set { _eventDate = value; base.RaisePropertyChanged("EventDate"); } }

        /// <summary>
        /// Indicates if the event recurs.
        /// </summary>
        public bool IsRecurring { get { return _isRecurring; } set { _isRecurring = value; base.RaisePropertyChanged("IsRecurring"); } }

        /// <summary>
        /// The interval the event recurs.
        /// </summary>
        public int RecurringInterval { get { return _recurringInterval; } set { _recurringInterval = value; base.RaisePropertyChanged("RecurringInterval"); } }

        /// <summary>
        /// The type of recurrance the event observes.
        /// </summary>
        public EventIntervalTypes RecurringIntervalType { get { return _recurringIntervalType; } set { _recurringIntervalType = value; base.RaisePropertyChanged("RecurringIntervalType"); } }

        /// <summary>
        /// Indicates the active status of the event.
        /// </summary>
        public bool IsActive { get { return _isActive; } set { _isActive = value; base.RaisePropertyChanged("IsActive"); } }

        /// <summary>
        /// Comments associated with this event.
        /// </summary>
        public ObservableCollection<CommentViewModel> Comments
        {
            get
            {
                if (_comments == null) { _comments = new ObservableCollection<CommentViewModel>(); }
                return _comments;
            }
            set
            {
                _comments = value;
                base.RaisePropertyChanged("Comments");
            }
        }

        /// <summary>
        /// Library items associated with this project.
        /// </summary>
        public ObservableCollection<LibraryItemViewModel> Library
        {
            get
            {
                if (_library == null) { _library = new ObservableCollection<LibraryItemViewModel>(); }
                return _library;
            }
            set
            {
                _library = value;
                base.RaisePropertyChanged("Library");
            }
        }
    }
}